#include "qelineedit.h"
#include "keyboard_interface.h"
#include "keyboard_adaptor.h"

#include <QtCore/QEvent>
#include <QAction>

FocusInEventFilter::FocusInEventFilter(QObject * receiver, const char *
member)
        : QObject() {
        //SAFE_CONNECT_RECEIVER(this, SIGNAL(activate(QEvent *)),receiver, member);
}

void FocusInEventFilter::filter(QEvent * event) {
        event->accept();
}

/*FocusInEventFilter::FocusInEventFilter(QObject * receiver, const char *
member)
        : EventFilter(receiver, member) {
}*/

bool FocusInEventFilter::eventFilter(QObject * watched, QEvent * event)
{
                if (event->type() == QEvent::FocusIn) {
                filter(event);
                return true;
        }
        return false;// EventFilter::eventFilter(watched, event);
}


QELineEdit::QELineEdit(QWidget * parent) : QLineEdit(parent){
    this->installEventFilter(new FocusInEventFilter(this,SLOT(FocusInEvent())));
}

QELineEdit::~QELineEdit(){
}

/*void QELineEdit::setFocus(Qt::FocusReason Focus){
    this->focusWidget()->setFocus(Focus);
    int type = 0;
    QDBusMessage msg = QDBusMessage::createSignal("/", "com.opendesk.keyboard", "show");
    msg << type;
    QDBusConnection::sessionBus().send(msg);
}
*/

void QELineEdit::FocusInEvent(){
    int type = 0;
    QDBusMessage msg = QDBusMessage::createSignal("/", "com.opendesk.keyboard", "show");
    msg << type;
    QDBusConnection::sessionBus().send(msg);
    this->setText("CIAO");
}
